<?php
  session_start();
  header ("Content-Type: text/html; charset=UTF-8");
  include("./config.php");
  $tpl = new PhplibTpl("templates");
  if (! empty($_GET['mode']) )
  {   
    include($conf["include_path"] . $_GET['mode'] . ".php");
  }
  $tpl -> set_file(array("page" => "unit_type.htm"));
  $tpl -> set_block("page","UNT_LIST","unt_list");

 /* 显示所有的单位类型 */
  $query = "SELECT * FROM $TBL_UNTY ORDER BY unt_order ASC";
  //实现分页
  include( $conf['base_path'] . "lib/make_pages.php");
  $cur_page = (int)$_GET["p"];   //获取当前页
  $url_param = preg_replace("/(p=[0-9]+)&/", "", $_SERVER['QUERY_STRING']);
  $pages = new Pager($query, $cur_page, 20, $url_param);
  $page_string = $pages -> getPageString();   
  $result = $pages -> getRsPerPage();
  while ($rows = mysql_fetch_array($result))
  {
    $edit_url = "?mode=add_untype&id=".$rows["unt_id"]; //友情链接ID
	$tpl -> set_var(array(
	                      "EDIT_URL" => $edit_url,
	                     ));
	$tpl -> set_var( $rows);
    $tpl -> parse("unt_list", "UNT_LIST", true);
  }
  $page_string = empty($page_string) ? "此条件下暂無单位类型!" : $page_string;

  $tpl -> set_var(array(
                        "PAGE_STRING" => $page_string
					   ));
  $tpl -> set_var( $conf);
  $tpl -> parse("Output","page");
  $tpl -> p("Output");
?>
